// testing global as described in http://www.w3schools.com/jsref/obj_window.asp

// window.alert		TESTED
// history.back		TESTED
// location.reload	TESTED
// ?? window.blur, window.focus, other designlike functions ?? IGNORED //


// Window properties (2 as an example)
try {
	assertFalse(window.closed);
	assertTrue(window.history instanceof History);
	assertTrue(window.location instanceof Location);
	assertTrue(window.navigator instanceof Navigator);
	success("instanceof");
	success("window properties (closed, history, location, navigator)");

	} catch(e) {
	alert(e.name + ": " + e.message);
}

// Window setInterval / clearInterval / setTimeoutTest
try{
	var value = 0,testval = 0;
	var updater;
	function updateVal()
	{
		value++;
	}
	var updater = window.setInterval(updateVal,1000);
	function checkUpdateVal2()
	{
		assertEquals(testval,value);
		success("window.clearInterval");
	}
	
	function checkUpdateVal()
	{
		success("window.setTimeout");
		assertFalse(value === 0);
		success("window.setInterval");
		window.clearInterval(updater);
		testval = value;
		window.setTimeout(checkUpdateVal2,1100);
	}
	window.setTimeout(checkUpdateVal,1100);
}
catch(e){
	alert(e.name + ": " + e.message);
}

// window.confirm
try {
	assertTrue(window.confirm("please press ok"));
	assertFalse(window.confirm("please press cancel"));
	success("window.confirm");
} catch(e) {
	alert(e.name + ": " + e.message);
}
// window.prompt
try {
	assertEquals(window.prompt("please press cancel",""),null);
	assertEquals(window.prompt("leave blank and press ok",""),"");
	assertEquals(window.prompt("please type 'test' and press ok","test"),"test");
	success("window.prompt");
} catch(e) {
	alert(e.name + ": " + e.message);
}

// window.open / window.close
try {
	var myWin = window.open("http://www.w3schools.com");
	assertFalse(myWin.closed);
	success("window.open");
	myWin.close();
	assertTrue(myWin.closed);
	success("window.close");
} catch(e) {
	alert(e.name + ": " + e.message);
}
// document === window.document
try{
	assertFalse(window.document.cookie.indexOf("testcookie") == -1);
	success("window.document.cookie");
	assertFalse(window.document.URL.indexOf("kul") == -1);
	success("window.document.URL");
	assertEquals(document,window.document,"document === window.document");
	success("document === window.document");
	// next fails in IE too
	assertTrue(document instanceof Document);
	success("document instanceof Document");
	assertTrue(window.document instanceof Document);
	success("window.document instanceof Document");
} catch(e) {
	alert(e.name + ": " + e.message);
}
